package com.baixun.gassystem.mapper;

import com.baixun.gasentity.dto.BackOfficeUserInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @program: 上海燃气驾驶舱
 * @description: 后台管理系统用户管理用户信息
 * @author: yesong
 **/
public interface BackOfficeUserInfoMapper extends BaseMapper<BackOfficeUserInfo> {
    /**
     * 获取部门下的所有用户
     * @return 用户信息列表
     */
    @Select("SELECT\n" +
            "    sd.user_id AS userId,\n" +
            "    sd.user_name AS userName,\n" +
            "    sd.department_name AS departmentName,\n" +
            "    su.tel AS tel\n" +
            "FROM\n" +
            "    sys_department_user sd\n" +
            "JOIN\n" +
            "    sys_user su\n" +
            "ON\n" +
            "    sd.user_id = su.id")
    List<String> getAllUserInfo();

    /**
     * 根据名称查询用户信息
     * @param userName 用户名
     * @return 用户信息
     */
    @Select("SELECT\n" +
            "    sd.user_id AS userId,\n" +
            "    sd.user_name AS userName,\n" +
            "    sd.department_name AS departmentName,\n" +
            "    su.tel AS tel\n" +
            "FROM\n" +
            "    sys_department_user sd\n" +
            "JOIN\n" +
            "    sys_user su\n" +
            "ON\n" +
            "    sd.user_id = su.id\n" +
            "WHERE\n" +
            "    sd.user_name = #{userName}")
    String getUserInfoToName(String userName);

}
